<template>
	<view class="house">
		<life-empty v-if="!houseList.length" url="/pkg-house/add-house/add-house" @click-text="onClick" tip="您还没有认证房屋，请点击"></life-empty>
		
		<view v-else class="house-list">
			<house-item></house-item>
			<house-item></house-item>
			<house-item></house-item>
			<life-button icon="../../static/icon/add.png" @click="toAddNewHouse" >添加新房屋</life-button>
		</view>
	</view>
</template>

<script>
	import { getHouseList } from '../../api/house.js'
	export default {
		data() {
			return {
				houseList: []
			}
		},
		
		onLoad(){
			this.loadHouseList()
		},
		
		methods: {
			onClick(){
				console.log('123');
			},
			
			async loadHouseList() {
				const res = await getHouseList()
				console.log(res);
				this.houseList = res.data
			},
			
			// 底部的添加新房屋
			toAddNewHouse() {
				uni.navigateTo({
					url: '/pkg-house/add-house/add-house'
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.house {
		height: 100%;
		background-color: #fafafa;
		
		.house-list {
			padding: 40rpx;
		}
	}

</style>
